<?php

namespace App\Models;

use DB;
use Illuminate\Database\Eloquent\Model;

class Cts extends Model
{
    protected $table = 'cts';
    protected $guarded = [];

    public function fromDateTime($value){
        return strtotime(parent::fromDateTime($value));
    }

    public function area()
    {
        return $this->belongsTo('App\Models\Area');
    }
    public static function groupWithCount($field)
    {
        $data = self::select([$field,DB::raw('Count('.$field.') as count')])->groupBy($field)->get();
        return $data;
    }

}
